#include "LogMessage.hpp"
#include "Thread.hpp"
#include "ThreadPool.hpp"
#include "caculator.hpp"

#include <unistd.h>

int main()
{
    srand((unsigned int)time(nullptr));
    loadCal();

    // 主线程创建所有从线程
    ThreadPool<Calculator>::GetThreadPoolPtr()->RunAllThread();

    // 主线程派发任务
    while(1)
    {
        sleep(1);
        int x = rand() % 200 + 1;
        int y = rand() % 100 + 1;
        int index = rand() % 4;
        LogMessage(NORMAL, _F, _L, "主线程派发任务 :: %d %c %d = ?", x, kv[index].first, y);
        ThreadPool<Calculator>::GetThreadPoolPtr()->PushTask(Calculator(x, y, kv[index].second, index));
    }

    return 0;
}